package com.zego.wawaji.ui.coupon.dialog;

import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.zego.wawaji.R;
import com.zego.wawaji.ui.UIShow;
import com.zego.wawaji.ui.coupon.bean.Coupon;
import com.zego.wawaji.ui.dialog.popup.BottomPopup;
import com.zego.wawaji.wawaji_client.AppTinkerLike;

/**
 * 获得优惠券弹框
 * Created by Su on 2018/2/8.
 */
public class CouponDialog extends BottomPopup {
    private Coupon coupon;

    public CouponDialog(FragmentActivity activity, Coupon coupon) {
        super(activity);
        this.coupon = coupon;
    }

    @Override
    protected View makeContentView() {
        View inflate = LayoutInflater.from(activity).inflate(R.layout.coupon_get_dialog, null);

        TextView tv_num = (TextView) inflate.findViewById(R.id.tv_num);
        TextView tv_title = (TextView) inflate.findViewById(R.id.tv_title);
        TextView tv_remark = (TextView) inflate.findViewById(R.id.tv_remark);
        if (coupon != null) {
            tv_num.setText(String.valueOf(coupon.getWwCoinZs()));
            tv_title.setText(coupon.getTitle());
            tv_remark.setText(coupon.getRemark());
        }

        inflate.findViewById(R.id.btn_submit).setOnClickListener(v -> UIShow.showCouponActivity(AppTinkerLike.getActivity()));
        inflate.findViewById(R.id.btn_close).setOnClickListener(v -> dismiss());
        return inflate;
    }
}
